From 73ba043b02d0db4e0059d4fafad5efad1ace9ff5 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 27 Feb 2023 19:43:11 -0500 Subject: [PATCH] text: Make editable API irreversible Programmatic changes to the entry contents should not become part of the undo history. Sadly, the editable implementations are also used in the code paths that we use for user-initiated changes, so we have to be careful to only set them as irreversible if we are not already in a user action. Fixes: #5622 --- gtk/gtktext.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gtk/gtktext.c b/gtk/gtktext.c index f71230ae09..9d11aa2d2a 100644 --- a/gtk/gtktext.c +++ b/gtk/gtktext.c @@ -3402,11 +3402,15 @@ gtk_text_insert_text (GtkText *self, * The incoming text may a password or other secret. We make sure * not to copy it into temporary buffers. */ + if (priv->change_count == 0) + gtk_text_history_begin_irreversible_action (priv->history); begin_change (self); n_inserted = gtk_entry_buffer_insert_text (get_buffer (self), *position, text, n_chars); end_change (self); + if (priv->change_count == 0) + gtk_text_history_end_irreversible_action (priv->history); if (n_inserted != n_chars) gtk_widget_error_bell (GTK_WIDGET (self)); @@ -3428,11 +3432,16 @@ gtk_text_delete_text (GtkText *self, if (start_pos == end_pos) return; + if (priv->change_count == 0) + gtk_text_history_begin_irreversible_action (priv->history); begin_change (self); gtk_entry_buffer_delete_text (get_buffer (self), start_pos, end_pos - start_pos); end_change (self); + if (priv->change_count == 0) + gtk_text_history_end_irreversible_action (priv->history); + update_placeholder_visibility (self); if (priv->propagate_text_width) gtk_widget_queue_resize (GTK_WIDGET (self)); -- 2.30.2